package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.CpDao;
import com.hzqy.persistence.dao.statistics.SchoolListenDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataCpVo;
import com.hzqy.web.vo.statistics.UserListenHistoryVo;

@Service
public class SchoolListenServiceBean extends GenericServiceBean<PmsUserVo, SchoolListenDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private SchoolListenDao slDao;
	
	@Override
	public SchoolListenDao getEntityDao() {
		return slDao;
	}
	public Map<String,Object> school_listen( UserListenHistoryVo ulhVo, int curPage,int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = slDao.school_listenCount(ulhVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_ulh_serverid", ulhVo.getF_ulh_serverid());
			map.put("beginDate", ulhVo.getBeginDate());
			map.put("endDate", ulhVo.getEndDate());
			List<UserListenHistoryVo> results = slDao.school_listenList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<UserListenHistoryVo>());
		}
		return map;
	}
	public Map<String, Object> school_listen_excel_list(
			 UserListenHistoryVo ulhVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = slDao.school_listenCount(ulhVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_ulh_serverid", ulhVo.getF_ulh_serverid());
			map.put("beginDate", ulhVo.getBeginDate());
			map.put("endDate", ulhVo.getEndDate());
			List<UserListenHistoryVo> results = slDao.school_listen_excelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<UserListenHistoryVo>());
		}
		return map;
	}
	public Map<String, Object> school_listen_zjh(
			 UserListenHistoryVo ulhVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("beginDate", ulhVo.getBeginDate());
		map.put("endDate", ulhVo.getEndDate());
		List<UserListenHistoryVo> results = slDao.school_listen_zjh(map);
		map.put("total", results.size());
		map.put("rows", results);
		return map;
	}
}